require([
    'jquery',
    'vue',
    'iview',
    'table-col-collapse',
    'role-manage-modal',
    'contabs',
    'CustomerAdd'
], function ($, Vue, iView, TableColCollapse, RoleManageModal, contabs, CustomerAdd) {
    Vue.use(iView)
    window.bus = new Vue();
    new Vue({
        el: "#app",
        components: {
            RoleManageModal: RoleManageModal,
            TableColCollapse: TableColCollapse,
            CustomerAdd: CustomerAdd,
        },
        data: {
            //系统字段设置开始
            systemFieldModal: false,
            showRoleManage: false,
            personalModal: false,

            //公司管理模块的添加新员工开始
            //添加新员工
            addNewStaffModal: false,
            //新建客源弹框内容开始
            AddClient: false,
            beforeMenuItemActive:'',
            /*客户导入弹框开始*/
            customerImport: false,
            /*客户导入弹框结束*/

            //登录员工姓名
            staffName:localStorage.userName,
        },
        methods: {
            handleMenuActive: function (e) {
                var target = $(e.target);
                if (target.hasClass('J_menuItem')) {
                    this.beforeMenuItemActive !== '' ? this.beforeMenuItemActive.removeClass('active') : '';
                    target.addClass('active');
                    this.beforeMenuItemActive = target;
                }
            },
            showCustomerAdd() {
                    window.bus.$emit("showCustomerAdd");
            }

        },
        mounted: function () {

        }
    });

    //新增小区大弹框的遮罩
    $(".addPlot").click(function () {
        $(".list-details").css({display: 'block'});
        $(".zhezhao").css({display: 'block'});
    })
    $(".clickClose").click(function () {
        $(".list-details").css({display: 'none'});
        $(".zhezhao").css({display: 'none'});
    })
    $(".zhezhao").click(function () {
        $(".list-details").css({display: 'none'});
        $(".zhezhao").css({display: 'none'});
    });
    //    新增小区弹框的点击加载更多
    $(".hot-moreBtn").click(function () {
        if ($(".houseTabHide").css("display") === "none") {
            $(".houseTabHide").stop().slideDown();
            $(".hot-moreBtn span").text("收起更多小区资料");
        } else {
            $(".houseTabHide").stop().slideUp();
            $(".hot-moreBtn span").text("加载更多小区资料");
            $(".houseTabBox").overflow = "hidden";
        }
    });

    //批量生成楼栋
    $(".batchCreateBdNum").prev().css({"position": "relative", "height": "0"});
    $(".batchCreateBdNum").find(".ivu-modal").css("box-shadow", "0px 1px 10px rgba(0,0,0,0.5)");

    //批量生成房号
    $(".batchCreateHsNum").prev().css({"position": "relative", "height": "0"});
    $(".batchCreateHsNum").find(".ivu-modal").css("box-shadow", "0px 1px 10px rgba(0,0,0,0.5)");


    /*弹框输入姓名*/
    // $("#customer").bind("input propertychange", function () {
    //     $(".c-shuru").show().html("<em>" + $("#customer").val() + "先生" + "</em>" + "<em>" + $("#customer").val() + "女士" + "</em>");
    //     $(".c-shuru em").click(function () {
    //         $("#customer").val($(this).text());
    //         $(".c-shuru").hide();
    //     })
    // });


    //个人中心 可编辑内容切换
    $(".editToggleBtn").click(function () {
        $(".personalEdit").addClass("personalBlock").removeClass(".personalNone");
        $(".personaNoEdit").addClass("personalNone");
        $(".personalWrap .ivu-modal-footer").addClass("personalBlock");
    });


    //小区的 弹框的放大和缩小

    /*点击切换大框大小*/
    $(".clickBig").click(function () {
        $(".list-details").animate({
            width: $(".wrap").width() - 160,
            height: $(".wrap").height() - 60,
            'margin-left': -$(".wrap").width() / 2 + 160,
            'margin-top': -$(".wrap").height() / 2
        })
        $(".message-box").animate({width: '100%', height: '100%'})
        $(".modal-content").animate({height: '100%'})
        $(".modal-content-right").animate({height: '100%'})
        $(".clickBig").hide();
        $(".clickMin").show();
    })
    $(".clickMin").click(function () {
        $(".list-details").animate({width: '1100px', height: '577px', 'margin-left': -'470', 'margin-top': -'305'});
        $(".clickBig").show();
        $(".clickMin").hide();
    })

    $(window).resize(function () {
        $(".list-details").animate({width: '1100px', height: '577px', 'margin-left': -'470', 'margin-top': -'305'});
        $(".clickBig").show();
        $(".clickMin").hide();
    }).resize();

    // 启用多窗口
    contabs();
    // 左边导航宽度自适应的js
    $(".main-nav a").click(function () {
        var width = $(".page-tabs-content").innerWidth();
        var size = $("#top-nav a").size();
        var wWidth = width;
        var mWidth = wWidth / (size - 1)
        var aWidth = (mWidth) / width;
        $("#top-nav a").css({"width": aWidth * 100 + "%"})
        $("#top-nav .home-a").css({"width": "52px"})
    });

    $('.exit-btn a').click(function () {
        if (confirm('确定要登出系统')) {
            localStorage.removeItem('SecurityManager.key');
            localStorage.removeItem('SecurityManager.Secret');
            window.location.replace(window.location.origin+'/views/login/login.html');
        }
    });
})
